<template>
    <div>
            <table>
                <thead>
                    <tr>
                        <td>卡卷名称:</td>
                        <td><input type="text" v-model="data.kjName"></td>
                    </tr>
                    <tr>
                        <td>卡卷类型:</td>
                        <td>
                                        <select  v-model="data.tid">
                                <option value="0">请选择</option>
                                <option v-for="b in Types" :value="b.tid">{{b.typeName}}</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>适用范围:</td>
                        <td>
                                    <select  v-model="data.mid">
                            <option value="0">请选择</option>
                            <option v-for="b in Mens" :value="b.mid">{{b.mname}}</option>
                        </select>
                        </td>
                    </tr>
                    <tr>
                        <td>适用日期:</td>
                        <td>
                            <span v-for="a in riqi">
                                <input v-model="data.yxTimes" type="checkbox" :value="a">{{a}}
                            </span>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>有效期:</td>
                        <td><input type="text" v-model="data.times"></td>
                    </tr>
                    <tr>
                        <td>价格:</td>
                        <td><input type="text" v-model="data.price"></td>
                    </tr>
                    <tr>
                        <td>状态:</td>
                        <td>
                            <input v-model="data.zt" type="checkbox" value="true">上架
                            <input v-model="data.zt" type="checkbox" value="false">下架
                        </td>
                    </tr>
                    <tr>
                        <td>图片:</td>
                        <td>
                            <input type="file" >
                            <img :src="'https://localhost:7008/'+data.img" style="width: 60px; height: 60px;">
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type="button" value="修改" @click="Showdasdw"></td>
                    </tr>
                </thead>
            </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'
import { useRoute } from 'vue-router';


const route =useRoute();
const router =useRouter();

const riqi = ref(["周一","二","三","四","五"]);


onMounted(() => {
    Show()
    Men()
    Type()
})

const Mens = ref([
{
    "mid": 1,
    "mname": "门店1"
  }
]);
const Types = ref([
{
    "tid": 1,
    "typeName": "时长卡"
  }
]);

const data = ref(
    {
  "hid": 1,
  "kjName": "两个小时的",
  "tid": 0,
  "mid": 0,
  "times": "string",
  "yxTimes": "string",
  "price": "string",
  "zt": true,
  "luoji": true,
  "img": "string"
}
)

const Men=()=>{
    axios.get("https://localhost:7008/api/Hotel/ChaMendian").then(res=>{
        Mens.value=res.data;
    })
}
const Type=()=>{
    axios.get("https://localhost:7008/api/Hotel/ChaType").then(res=>{
        Types.value=res.data;
    })
}

const Show=()=>{
    axios.get("https://localhost:7008/api/Hotel/Fantian",{params:{id:route.query.id}}).then(res=>{
        data.value=res.data;
        data.value.times=data.value.times.split(",").toString();
    })
}

const Showdasdw=()=>{
    alert("修改成功");
    router.push({path:'/'})
}



</script>

<style scoped>

</style>
